/*
 * @Author: dujianmin@qq:20130527 
 * @Date: 2024-07-20 00:09:28 
 * @Last Modified by: dujianmin
 * @Last Modified time: 2024-07-20 02:30:13
 */
#pragma once

#include <stdio.h>

#include "esp_system.h"
#include "nvs_flash.h"
#include "esp_event.h"


#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "freertos/event_groups.h"

#include "esp_log.h"
#include "esp_websocket_client.h"
#include "esp_event.h"
#include <cJSON.h>

#define NO_DATA_TIMEOUT_SEC 20
#define MAX_CONTENT_LENGTH 1024
#define MAX_AUDIO_LENGTH   1024

typedef struct {
    union {
        char stt_content[MAX_CONTENT_LENGTH];
        char chat_content[MAX_CONTENT_LENGTH];
        char tts_content[MAX_AUDIO_LENGTH];
    } data;
    int dataType;  // Indicates which type of data is currently valid (0: stt_content, 1: content, 2: tts_content)
} WebSocketData;

extern WebSocketData received_data;

typedef void (*DataCallback)(const char *data);
void websocket_app_start_init(void);


void websocket_app_start_chat(char * url ,char * chat_message, DataCallback callback);

void websocket_app_start_tts(char * url ,char * tts_message, DataCallback callback);

void websocket_app_start_stt(char * url ,  char * file_name, DataCallback callback);

